#ifndef _ROB_IR_RC_H
#define _ROB_IR_RC_H

#include <WProgram.h>
#include <avr/io.h>

// IR_Sensor must be connected to INT0-Pin: 2


// Remote Control Declaration / Definitions
#define REMOTE_WITH_REPEAT 1
#define REMOTE_WIHOUT_REPEAT 0



// Remote Control Macro Functions
#define INT0_RISING() { EICRA |= ( (1 << ISC01) | (1 << ISC00) ); }
#define INT0_FALLING() { EICRA = (EICRA | (1 << ISC01)) & ~(1 << ISC00); }
#define INT0_ANY() { EICRA = (EICRA & ~(1 << ISC01)) | (1 << ISC00); }
#define INT0_IRQ_ENABLE() {EIMSK |= ( 1 << INT0); }
#define INT0_IRQ_DISABLE() {EIMSK &= ~( 1 << INT0); }
#define INT0_IRQ_CLEAR() { EIFR |= ( 1 << INTF0 ); }



// externals

extern volatile uint8_t        IR_remote_with_repeat; // set to 1 in remote_init to analyze repeat commands from IR sender
extern volatile uint8_t        IR_remote_available; // becomes 1 when a new command is available
extern volatile uint32_t       IR_remote_data; // stored result: actual command



// Prototypes

void IR_remote_init(uint8_t with_repeat);



#endif // _ROB_IR_RC_H
